package com.rx.mgt.dao;

import com.rx.mgt.dao.base.ManagementHibernateDaoBase;
import com.rx.mgt.domain.EmailListMember;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by zxj on 2017/5/26.
 */
@Repository
public class EmailListMemberDao extends ManagementHibernateDaoBase<EmailListMember,Long> {

    public List<EmailListMember> getEmailListMembersByEmaiListId(String id) {
        String hql = " from EmailListMember e where 1=1";
        hql =hql+" and e.emailListId =:emailListId";
        Query query = template.getSessionFactory().getCurrentSession().createQuery(hql);
        query.setParameter("emailListId",Long.valueOf(id));
        return query.list();

    }

    public EmailListMember getOne(String hql,String email) {
        Query query = template.getSessionFactory().getCurrentSession().createQuery(hql);
        query.setParameter("email",email);
        return (EmailListMember)query.uniqueResult();
    }
}
